<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        // 代理+反射
        let formData = {
            account: "admin",
            password: '123456'
        };
        let handel = {
            set: function (target, key, value) {
                if (value.length < 6 || value.length > 20) {
                    return;
                }
                target[key] = value;
            },
            get: function (target, key) {
                console.log('get函数被调用：', target, key)
                return target[key];
            }
        }
        formData = new Proxy(formData, handel);
        Reflect.set(formData, 'account', 'admin123');
        Reflect.set(formData, 'account', '123');

        let account = Reflect.get(formData, 'account');
        let password = Reflect.get(formData, 'password');
        console.log(account, password);
    </script>
</body>

</html>